﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using QingzimaLogicModel;
using Jacaranda.Model;
using QingzimaDB;

namespace QingzimaScenario
{
    public class GongsijieshaoScenario
    {
        public static GongsijieshaoLM HuoquByID(int id)
        {
            return ConvertToLM(Database.SearchOne<GongsijieshaoDB>(new AbstractProperty("ID") == id));
        }

        public static List<GongsijieshaoLM> HuoquModels()
        {
            List<GongsijieshaoLM> tempLMList = new List<GongsijieshaoLM>();
            foreach (GongsijieshaoDB dbModel in Database.All<GongsijieshaoDB>())
            {
                tempLMList.Add(ConvertToLM(dbModel));
            }
            return tempLMList;
        }

        public static void Tianjia(GongsijieshaoLM gongsijieshaoLM)
        {
            gongsijieshaoLM.Save();
        }

        private static GongsijieshaoLM ConvertToLM(GongsijieshaoDB dbModel)
        {
            return dbModel == null ? null : new GongsijieshaoLM(dbModel);
        }
    }
}
